package com.crm.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
	
	private HibernateUtil(){}

	private static SessionFactory factory;
	
	public static SessionFactory getSessionFactory() {
		if(factory == null) {
			Configuration cfg = new Configuration().configure();
			factory = cfg.buildSessionFactory();
		}
		return factory;
	}
	
	public static Session getSession() {
		return getSessionFactory().getCurrentSession();
	}
}
